package com.zork.data.generator.controller;

import com.alibaba.fastjson.JSON;
import com.zork.data.generator.model.NodeRelationInfo;
import com.zork.data.generator.model.TopologyInfo;
import com.zork.data.generator.service.ArchService;
import com.zork.data.generator.service.TopologyInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xiesen
 */
@RestController
@Slf4j
@RequestMapping("/topo")
public class TopologyInfoController {
    @Resource
    TopologyInfoService topologyInfoService;

    @Resource
    ArchService archService;

    @GetMapping("/list")
    public String list() {
        final List<TopologyInfo> topologyInfos = topologyInfoService.searchAll();
        return JSON.toJSONString(topologyInfos);
    }

    @GetMapping("/nodeRelation")
    public String nodeRelation() {
        final List<NodeRelationInfo> list = archService.nodeRelation();
        return JSON.toJSONString(list);
    }
}
